/*
 * NewWSGraphPanel.java
 * Created on Aug 6, 2010
 */

package graphexplorer.dialogs;

import org.bm.blaise.scio.graph.Graph;
import org.bm.blaise.scio.graph.WattsStrogatzRandomGraph;

/**
 *
 * @author elisha
 */
public class NewWSGraphPanel extends javax.swing.JPanel {


    /** Creates new form NewRandomGraphPanel */
    public NewWSGraphPanel() {
        initComponents();
    }

    /** @return graph corresponding to the current graph settings */
    public Graph<Integer> getInstance() {
        int order = basicP.getOrder();
        int deg = (Integer) avgDegS.getValue();
        float rewiring = (Float) rewiringS.getValue();
        return WattsStrogatzRandomGraph.getInstance(order, deg, rewiring);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        basicP = new graphexplorer.dialogs.NewSimpleGraphPanel(30,100000,true);
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        avgDegS = new javax.swing.JSpinner();
        jLabel2 = new javax.swing.JLabel();
        rewiringS = new javax.swing.JSpinner();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Edge Generation Method"));
        jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        jLabel1.setText("average degree:");
        jPanel1.add(jLabel1);

        avgDegS.setModel(new javax.swing.SpinnerNumberModel(4, 0, 1000, 2));
        avgDegS.setToolTipText("Enter the average degree of the resulting graph (must be even)");
        jPanel1.add(avgDegS);

        jLabel2.setText("rewiring probability");
        jPanel1.add(jLabel2);

        rewiringS.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.1f), Float.valueOf(0.0f), Float.valueOf(1.0f), Float.valueOf(0.05f)));
        rewiringS.setToolTipText("Enter the probability of occurence for each edge in the resulting graph (0.00-1.00)");
        rewiringS.setPreferredSize(new java.awt.Dimension(70, 22));
        jPanel1.add(rewiringS);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(basicP, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(basicP, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JSpinner avgDegS;
    private graphexplorer.dialogs.NewSimpleGraphPanel basicP;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSpinner rewiringS;
    // End of variables declaration//GEN-END:variables

}
